home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Borland Plateform / Turbo Prolog 2 / EXAMPL61.PRO < prev    next >
Encoding:
Prolog Source  |  1986-04-25  |  625 b   |  18 lines

  1.          /* program 61 */
  2.     
  3. predicates
  4.   plus(integer,integer,integer)
  5.   numb(integer)
  6. clauses
  7.   plus(X,Y,Z):- bound(X),bound(Y),Z=X+Y.       
  8.   plus(X,Y,Z):- bound(X),bound(Z),Y=Z-X.       
  9.   plus(X,Y,Z):- bound(Z),bound(Y),X=Z-Y.         
  10.   plus(X,Y,Z):- free(X),free(Y),bound(Z),numb(X), Y=Z-X.         
  11.   plus(X,Y,Z):- free(X),free(Z),bound(Y),numb(X), Z=X+Y.         
  12.   plus(X,Y,Z):- free(Y),free(Z),bound(X),numb(Y), Z=X+Y.         
  13.   plus(X,Y,Z):- 
  14.        free(X),free(Y),free(Z),numb(X),numb(Y),Z=X+Y.       
  15.  
  16.        /* Generator of numbers starting at 0 */
  17.   numb(0).
  18.   numb(X) :- numb(A), X=A+1.